package cn.qzbook.controller;

import cn.qzbook.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/changeSex")
public class ChangeSexBatch extends HttpServlet {

    private UserService userService =  new UserService();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");


        String[] ids = req.getParameterValues("id");
        String sex = req.getParameter("sex");

        userService.changeSexBatch(sex,ids);

        resp.sendRedirect("/");

    }
}
